﻿using Newtonsoft.Json.Linq;
using SDF.Core.Infrastructure;
using SDF.Plugin.Misc.SAPAdapter.Models;
using SDF.Plugin.Misc.SAPAdapter.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SDF.Plugin.Misc.SAPAdapter.Controllers.Version1
{
    public class ExecuteSAPFunctionController : SAPWebApiBase
    {
        ISAPConnectorService _sapService;

        ExecuteSAPFunctionController()
        {
            _sapService = EngineContext.Current.Resolve<ISAPConnectorService>();
        }

        public ExecuteSAPFunctionAPIModel Post(ExecuteSAPFunctionAPIModel model)
        {
            var data = _sapService.ExecuteSAPFunction(model.SAPInstance, model.FunctionName, model.Data);
            model.Data = data;

            return model;
        }
    }
}